package com.yeung.exam;

import java.util.Scanner;
import java.util.Stack;

/**
 * HG[3|B[2|CA]]F
 */
public class 解压缩 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        char[] lins = line.toCharArray();
        Stack<Character> stack = new Stack<>();
        for (char lin : lins) {
            if (lin != ']')
                stack.push(lin);
            else {
                //
                StringBuilder sb = new StringBuilder();

                while (!stack.empty()) {
                    Character pop = stack.pop();
                    if (pop == '[') break;
                    else
                        sb.append(pop);
                }
                StringBuilder revContent = sb.reverse();
                //解密一部分
                String[] split = revContent.toString().split("\\|");
                int times = Integer.valueOf(split[0]);
                StringBuilder ss = new StringBuilder();
                while (times > 0) {
                    ss.append(split[1]);
                    times--;
                }
                //入栈
                char[] chars = ss.toString().toCharArray();
                for (char aChar : chars) {
                    stack.push(aChar);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        while (!stack.empty())
            sb.append(stack.pop());
        System.out.println(sb.reverse().toString());
    }

}
